package com.zr.datamodel;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="sys_role")
public class RoleDM {

	//角色id
	private int id;
	
	//角色名
	private String name;
	
	//角色下的用户
	private List<UserDM> users = new ArrayList<>();
	
	//角色对应得功能
	private List<FuncDM> funcs = new ArrayList<>();

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name="name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(mappedBy="role")
	public List<UserDM> getUsers() {
		return users;
	}

	public void setUsers(List<UserDM> users) {
		this.users = users;
	}

	@ManyToMany(mappedBy="roles")
	public List<FuncDM> getFuncs() {
		return funcs;
	}

	public void setFuncs(List<FuncDM> funcs) {
		this.funcs = funcs;
	}
	
}
